openapi: 3.0.1
info:
  title: LawVu Files
  description: Apis for files resources
  version: '1.0'
servers:
  - url: https://api-sandbox.lawvu.com/file-apis
    description: Sandbox API
  - url: https://api.lawvu.com/file-apis
    description: Production API
paths:
  /v1/files:
    get:
      tags:
        - Files
      summary: Get files
      description: Gets a list of files in LawVu (with filters)
      operationId: get-v1-files
      parameters:
        - name: recordType
          in: query
          description: >-
            The record type the file in linked to (Matter, Contract,
            Organisation
            etc)<p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
          schema:
            enum:
              - Matter
              - Milestone
              - Task
              - Organisation
              - Contract
              - File
              - InvoiceBatch
              - KnowledgeArticle
              - Folder
              - FolderTemplate
              - KnowledgeLibrary
              - InboundEmail
              - User
              - MessageThread
              - TimelineEntry
              - MatterStatus
              - ContractStatus
              - Message
              - Comment
            type: string
            description: >-
              <p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
        - name: recordId
          in: query
          description: The record id the file is linked to
          schema:
            type: integer
            format: int32
        - name: skip
          in: query
          description: The number of files to skip (used for paging)
          schema:
            type: integer
            format: int32
        - name: folderId
          in: query
          description: The folder id to get files from
          schema:
            type: integer
            format: int32
        - name: filtering.field
          in: query
          description: Field to filter by (optional)
          schema:
            type: string
        - name: filtering.operator
          in: query
          description: Operator used for filtering (optional)
          schema:
            enum:
              - eq
              - neq
              - lt
              - lte
              - gt
              - gte
              - startswith
              - endswith
              - contains
              - doesnotcon
              - isnull
            type: string
        - name: filtering.value
          in: query
          description: Value to filter by (optional)
          schema:
            type: string
        - name: sorting.direction
          in: query
          description: Set the sorting direction
          schema:
            enum:
              - asc
              - desc
            type: string
        - name: sorting.field
          in: query
          description: Set the sorting fields
          schema:
            type: string
        - name: take
          in: query
          description: 'The maximum number of files to return<p>Default: 50</p>'
          schema:
            type: integer
            format: int32
            default: 50
        - name: recursive
          in: query
          description: >-
            Set to true in order to include subdirectories and nested
            files<p>Default: False</p>
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/FileListItemDataSourceResult'
            application/json:
              schema:
                $ref: '#/components/schemas/FileListItemDataSourceResult'
            text/json:
              schema:
                $ref: '#/components/schemas/FileListItemDataSourceResult'
  /v1/files/{fileId}:
    get:
      tags:
        - Files
      summary: Get file
      description: Get file meta from LawVu
      operationId: get-v1-files-fileid
      parameters:
        - name: fileId
          in: path
          description: The Id of the file
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/FileDetailModel'
            application/json:
              schema:
                $ref: '#/components/schemas/FileDetailModel'
            text/json:
              schema:
                $ref: '#/components/schemas/FileDetailModel'
    delete:
      tags:
        - Files
      summary: Delete file
      description: Deletes a file in LawVu
      operationId: delete-v1-files-fileid
      parameters:
        - name: fileId
          in: path
          description: The Id of the file
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: Success
    patch:
      tags:
        - Files
      summary: Patch file
      description: Updates a file
      operationId: patch-v1-files-fileid
      parameters:
        - name: fileId
          in: path
          description: The Id of the file
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        description: >-
          JSON patch definition for the update. Currently only [name] is
          supported (file rename)
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/OperationArray'
          application/json:
            schema:
              $ref: '#/components/schemas/OperationArray'
          text/json:
            schema:
              $ref: '#/components/schemas/OperationArray'
          application/*+json:
            schema:
              $ref: '#/components/schemas/OperationArray'
      responses:
        '200':
          description: Success
  /v1/files/{fileId}/download:
    get:
      tags:
        - Files
      summary: Download file
      operationId: get-v1-files-fileid-download
      parameters:
        - name: fileId
          in: path
          description: The Id of the file
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                type: integer
                format: int32
            application/json:
              schema:
                type: integer
                format: int32
            text/json:
              schema:
                type: integer
                format: int32
  /v1/files/{fileId}/move/{destinationId}:
    post:
      tags:
        - Files
      summary: Move file
      description: >-
        Moves a file. If there is a conflict in the destination, set the
        ConflictResolution<br /><br />See notes for destinationId when moving a
        file to the root folder of a matter or contract
      operationId: post-v1-files-fileid-move-destinationid
      parameters:
        - name: fileId
          in: path
          description: The Id of the file
          required: true
          schema:
            type: integer
            format: int32
        - name: conflictResolution
          in: query
          description: >-
            Conflict
            handling<p>Options:</p><ul><li>Replace</li><li>KeepBoth</li><li>SaveVersion</li><li>Skip</li></ul>
          schema:
            enum:
              - Replace
              - KeepBoth
              - SaveVersion
              - Skip
            type: string
            description: >-
              <p>Options:</p><ul><li>Replace</li><li>KeepBoth</li><li>SaveVersion</li><li>Skip</li></ul>
        - name: destinationId
          in: path
          description: >-
            The destination location for the file.<br />If moving the file to
            the root folder of the matter or contract, omit this value from the
            path i.e. 'POST /{fileId}/move/'
          required: true
          schema:
            type: integer
            format: int32
      responses:
        '204':
          description: No Content
  /v1/files/{targetType}/{targetId}:
    post:
      tags:
        - Files
      summary: Upload file
      description: >-
        Upload a file to LawVu. The body of the post should be the contents of
        the file.
      operationId: post-v1-files-targettype-targetid
      parameters:
        - name: targetType
          in: path
          description: >-
            The target entity type in
            LawVu<p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
          required: true
          schema:
            enum:
              - Matter
              - Milestone
              - Task
              - Organisation
              - Contract
              - File
              - InvoiceBatch
              - KnowledgeArticle
              - Folder
              - FolderTemplate
              - KnowledgeLibrary
              - InboundEmail
              - User
              - MessageThread
              - TimelineEntry
              - MatterStatus
              - ContractStatus
              - Message
              - Comment
            type: string
            description: >-
              <p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
        - name: targetId
          in: path
          description: The target entity in LawVu
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        description: The upload details
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/UploadFilesRequest'
          application/json:
            schema:
              $ref: '#/components/schemas/UploadFilesRequest'
          text/json:
            schema:
              $ref: '#/components/schemas/UploadFilesRequest'
          application/*+json:
            schema:
              $ref: '#/components/schemas/UploadFilesRequest'
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                type: integer
                format: int32
            application/json:
              schema:
                type: integer
                format: int32
            text/json:
              schema:
                type: integer
                format: int32
  /v1/files/{targetType}/{targetId}/uploads/{uploadId}:
    put:
      tags:
        - Files
      summary: Finalise upload
      description: >-
        (communicate the outcome) of an individual file upload (which may be one
        of a set of files being uploaded)
      operationId: put-v1-files-targettype-targetid-uploads-uploadid
      parameters:
        - name: targetType
          in: path
          description: >-
            The target of the
            upload<p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
          required: true
          schema:
            enum:
              - Matter
              - Milestone
              - Task
              - Organisation
              - Contract
              - File
              - InvoiceBatch
              - KnowledgeArticle
              - Folder
              - FolderTemplate
              - KnowledgeLibrary
              - InboundEmail
              - User
              - MessageThread
              - TimelineEntry
              - MatterStatus
              - ContractStatus
              - Message
              - Comment
            type: string
            description: >-
              <p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
        - name: targetId
          in: path
          description: The id of the target type
          required: true
          schema:
            type: integer
            format: int32
        - name: uploadId
          in: path
          description: The id of the upload
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        description: The details of the finalisation
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/FinaliseUploadModel'
          application/json:
            schema:
              $ref: '#/components/schemas/FinaliseUploadModel'
          text/json:
            schema:
              $ref: '#/components/schemas/FinaliseUploadModel'
          application/*+json:
            schema:
              $ref: '#/components/schemas/FinaliseUploadModel'
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                type: integer
                format: int32
            application/json:
              schema:
                type: integer
                format: int32
            text/json:
              schema:
                type: integer
                format: int32
  /v1/folders:
    get:
      tags:
        - Folders
      summary: Get folders
      description: Gets a list of folders in LawVu
      operationId: get-v1-folders
      parameters:
        - name: recordId
          in: query
          description: The record ID the folders are linked to
          required: true
          schema:
            type: integer
            format: int32
        - name: recordType
          in: query
          description: >-
            The record type the folders are linked to (Matter, Contract,
            Organisation
            etc)<p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
          required: true
          schema:
            enum:
              - Matter
              - Milestone
              - Task
              - Organisation
              - Contract
              - File
              - InvoiceBatch
              - KnowledgeArticle
              - Folder
              - FolderTemplate
              - KnowledgeLibrary
              - InboundEmail
              - User
              - MessageThread
              - TimelineEntry
              - MatterStatus
              - ContractStatus
              - Message
              - Comment
            type: string
            description: >-
              <p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
        - name: parentFolderId
          in: query
          description: >-
            Returns folders under the specified parentd folder ID otherwise it
            returns them from the root folder
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: Success
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/FolderModelArray'
              example:
                - id: 1
                  name: Folder 1 test
                - id: 2
                  name: Folder 2 test
            application/json:
              schema:
                $ref: '#/components/schemas/FolderModelArray'
              example:
                - id: 1
                  name: Folder 1 test
                - id: 2
                  name: Folder 2 test
            text/json:
              schema:
                $ref: '#/components/schemas/FolderModelArray'
              example:
                - id: 1
                  name: Folder 1 test
                - id: 2
                  name: Folder 2 test
  /v1/folders/{targetType}/{targetId}:
    post:
      tags:
        - Folders
      summary: Create folder
      description: Creates a folder within a entity, optionally as a subfolder
      operationId: post-v1-folders-targettype-targetid
      parameters:
        - name: targetType
          in: path
          description: >-
            The target type the folder should be created
            in<p>Options:</p><ul><li>Matter</li><li>Contract</li></ul>
          required: true
          schema:
            enum:
              - Matter
              - Contract
            type: string
            description: <p>Options:</p><ul><li>Matter</li><li>Contract</li></ul>
        - name: targetId
          in: path
          description: The target entity in LawVu
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        description: Details of the folder to create
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/CreateFolderRequest'
            example:
              name: New Folder
              parentFolderId: 4375767
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFolderRequest'
            example:
              name: New Folder
              parentFolderId: 4375767
          text/json:
            schema:
              $ref: '#/components/schemas/CreateFolderRequest'
            example:
              name: New Folder
              parentFolderId: 4375767
          application/*+json:
            schema:
              $ref: '#/components/schemas/CreateFolderRequest'
            example:
              name: New Folder
              parentFolderId: 4375767
      responses:
        '201':
          description: Created
          content:
            text/plain:
              schema:
                type: integer
                format: int32
            application/json:
              schema:
                type: integer
                format: int32
            text/json:
              schema:
                type: integer
                format: int32
components:
  schemas:
    CreateFolderRequest:
      required:
        - name
      type: object
      properties:
        name:
          minLength: 1
          type: string
          description: Name of the folder to create
        parentFolderId:
          type: integer
          description: >-
            The parent folder ID the folder will be created within, otherwise
            the folder is created at the root of the record.
          format: int32
          nullable: true
      additionalProperties: false
    FileDetailModel:
      type: object
      properties:
        id:
          type: integer
          format: int32
        type:
          enum:
            - Folder
            - File
          type: string
          description: <p>Options:</p><ul><li>Folder</li><li>File</li></ul>
        size:
          type: integer
          format: int64
        description:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        version:
          type: integer
          format: int32
        createdDateUtc:
          type: string
          format: date-time
        uploadedBy:
          type: string
          nullable: true
        path:
          type: string
          nullable: true
        isLocked:
          type: boolean
          readOnly: true
        isPrivate:
          type: boolean
        lockExpiryUtc:
          type: string
          format: date-time
          nullable: true
        documentId:
          type: string
          nullable: true
        externalContentType:
          type: string
          nullable: true
        externalWebUri:
          type: string
          nullable: true
        parentRecordId:
          type: integer
          format: int32
        parentRecordType:
          enum:
            - Matter
            - Milestone
            - Task
            - Organisation
            - Contract
            - File
            - InvoiceBatch
            - KnowledgeArticle
            - Folder
            - FolderTemplate
            - KnowledgeLibrary
            - InboundEmail
            - User
            - MessageThread
            - TimelineEntry
            - MatterStatus
            - ContractStatus
            - Message
            - Comment
          type: string
          description: >-
            <p>Options:</p><ul><li>Matter</li><li>Milestone</li><li>Task</li><li>Organisation</li><li>Contract</li><li>File</li><li>InvoiceBatch</li><li>KnowledgeArticle</li><li>Folder</li><li>FolderTemplate</li><li>KnowledgeLibrary</li><li>InboundEmail</li><li>User</li><li>MessageThread</li><li>TimelineEntry</li><li>MatterStatus</li><li>ContractStatus</li><li>Message</li><li>Comment</li></ul>
      additionalProperties: false
    FileListItem:
      type: object
      properties:
        id:
          type: integer
          format: int32
        type:
          enum:
            - Folder
            - File
          type: string
          description: <p>Options:</p><ul><li>Folder</li><li>File</li></ul>
        name:
          type: string
          nullable: true
        size:
          type: integer
          format: int64
        version:
          type: integer
          format: int32
        uploadedDateUtc:
          type: string
          format: date-time
        isPrivate:
          type: boolean
        uploadedBy:
          type: string
          nullable: true
        uploadedByOrganisation:
          type: string
          nullable: true
        fileModifiedDateUtc:
          type: string
          format: date-time
          nullable: true
        documentId:
          type: string
          nullable: true
        path:
          type: string
          nullable: true
      additionalProperties: false
    FileListItemDataSourceResult:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/FileListItem'
          description: Represents a single page of processed data.
          nullable: true
        total:
          type: integer
          description: The total number of records available.
          format: int32
      additionalProperties: false
    FinaliseUploadModel:
      type: object
      properties:
        outcome:
          enum:
            - Succeeded
            - Failed
          type: string
          description: <p>Options:</p><ul><li>Failed</li><li>Succeeded</li></ul>
        conflictResolution:
          enum:
            - Replace
            - KeepBoth
            - SaveVersion
            - Skip
          type: string
          description: >-
            <p>Options:</p><ul><li>Replace</li><li>KeepBoth</li><li>SaveVersion</li><li>Skip</li></ul>
          nullable: true
        failureReason:
          type: string
          nullable: true
        comments:
          type: string
          nullable: true
        isSigned:
          type: boolean
      additionalProperties: false
    FolderModel:
      type: object
      properties:
        id:
          type: integer
          description: Folder ID
          format: int32
        name:
          type: string
          description: Folder Name
          nullable: true
      additionalProperties: false
    FolderModelArray:
      type: array
      items:
        $ref: '#/components/schemas/FolderModel'
    Operation:
      type: object
      properties:
        value:
          type: object
          nullable: true
        path:
          type: string
          nullable: true
        op:
          type: string
          nullable: true
        from:
          type: string
          nullable: true
      additionalProperties: false
    OperationArray:
      type: array
      items:
        $ref: '#/components/schemas/Operation'
    UploadFilesRequest:
      type: object
      properties:
        folderId:
          type: integer
          description: Id of the folder for the file upload
          format: int32
          nullable: true
        isBrowsable:
          type: boolean
          description: File is browseable in the files collection
        fileData:
          type: string
          description: The upload file details
          format: binary
          nullable: true
      additionalProperties: false
